import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
import { DockerImageInfo, ContainerInfo } from './types/docker';

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  getHello(): string {
    return this.appService.getHello();
  }

  @Get('getDockerImages')
  listImages(): Promise<DockerImageInfo[]> {
    return this.appService.getDockerImages();
  }

  @Get('getRunningContainers')
  listRunningContainers(): Promise<ContainerInfo[]> {
    return this.appService.getRunningContainers();
  }

  @Delete(':imageIdOrName')
    deleteImage(@Param('imageIdOrName') imageIdOrName: string): Promise<void> {
        console.log(`Controller: Deleting image ${imageIdOrName}`);
        return this.dockerService.deleteImage(imageIdOrName);
    }
}
